package com.material.web.controller.pound;

import com.material.common.core.controller.BaseController;
import com.material.common.core.page.TableDataInfo;
import com.material.common.utils.SecurityUtils;
import com.material.pound.consts.PoundState;
import com.material.pound.domain.FuelPound;
import com.material.pound.params.FuelPoundQuery;
import com.material.pound.service.IFuelPoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
 * @author ganxinge
 */
@RestController
@RequestMapping("/pound/settle")
public class PoundSettleController extends BaseController {

    @Autowired
    private IFuelPoundService fuelPoundService;

    /**
     * 查询磅单信息列表
     */
    @PreAuthorize("@ss.hasPermi('pound:settle:list')")
    @GetMapping("/list")
    public TableDataInfo list(FuelPoundQuery fuelPound)
    {
        Long bizId = getBizId();
        boolean admin = SecurityUtils.isAdmin(getUserId());
        if(!admin){
            fuelPound.setFactoryId(bizId);
        }
        List<String> states = new ArrayList<>();
        states.add(String.valueOf(PoundState.STATE_5));
        states.add(String.valueOf(PoundState.STATE_6));
        states.add(String.valueOf(PoundState.STATE_7));
        fuelPound.setStateList(states);
        startPage();
        List<FuelPound> list = fuelPoundService.selectFuelPoundSettleList(fuelPound);
        return getDataTable(list);
    }
}
